<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<div>

    用户名 : <input type="text" id="userName">
    <br>
    密码 : <input type="password" id="password" onmouseover="method()" onmouseout="method()">
    <span id="password_span"></span>

</div>

<script>
    var elementById1 = document.getElementById("userName");
    var elementById2 = document.getElementById("password");
    var elementById3 = document.getElementById("password_span");

    function method() {
        if (elementById2.value == ""){
            elementById3.innerHTML="请输入密码"
        }else {
            elementById3.innerHTML=""
        }
    }

</script>

</body>
</html>